<?php 
		$showNextLink = false;
		$showPrevLink = false;

		if ($this->search->totalCount > ($this->search->first + 20)){
			$showNextLink = true;
			$fNext = $this->search->first + 20;
		}

		if ($this->search->first > 0){
			$showPrevLink = true;
			$fPrev = $this->search->first - 20;
		}
		
function viewRenderNavigation($view, $showNextLink, $showPrevLink)
{
	 if ($showNextLink) { ?>
	<input type="submit" name="nextButton" value="Next <?php print($view->resultsPerPage);?>">
<?php } ?>
<?php 
	if ($showPrevLink) { ?>
	<input type="submit" name="prevButton" value="Previous <?php print($view->resultsPerPage);?>">
<?php } 
	if ($view->search->totalCount > 0) { ?>
	<input type="submit" name="doneButton" value="Add Selected Materials">
<?php 
	}
}
		
?>
<div class="grid_15"><form name="navigation" method="get" action="./">
<div class="cancelNavigation">
	[ <a href="./?cmd=searchScreen&ci=<?php print($this->ci); ?>">New Search</a> ]
	[ <a href="./?cmd=editClass&ci=<?php print($this->ci); ?>">Cancel</a> ] 
</div>
	<h2>Searching for "<?php print(htmlentities($this->searchText)); ?>" in <?php print($this->searchField); ?></h2>
	<form class="bottomMargin" name="navigation" method="get" action="./">
<?php 
		$onThisPage = array();
		foreach($this->search->items as $searchIndex=>$item) {
			$onThisPage[] = $item->getId();
		}	
		
		if (is_array($this->hiddenReserves)){
			foreach($this->hiddenReserves as $r){
				if (!in_array($r,$onThisPage)) {
?>
	<input type="hidden" name="reserve[<?php print($r); ?>]" value="<?php print($r); ?>">
<?php 
				}
			}
		}
		if (is_array($this->hiddenRequests)){
			foreach($this->hiddenRequests as $r){
				if (!in_array($r,$onThisPage)) {
?>
	<input type="hidden" name="request[<?php print($r); ?>]" value="<?php print($r); ?>">
<?php 
				}
			}
		}
		if (is_array($this->hiddenLoanPeriods)){
			foreach($this->hiddenLoanPeriods as $r => $l){
				if (!in_array($r,$onThisPage)) {
?>
	<input type="hidden" name="loanperiod[<?php print($r); ?>]" value="<?php print($l); ?>">
<?php 
				}
			}
		}
?>
	<input type="hidden" name="cmd" value="searchResults">
	<input type="hidden" name="ci" value="<?php print($this->ci); ?>">
	<input type="hidden" name="f" value="<?php print($this->pageNumber);?>">
	<input type="hidden" name="e" value="<?php print($this->resultsPerPage);?>">
	<input type="hidden" name="searchField" value="<?php print($this->searchField); ?>">
	<input type="hidden" name="searchTerm" value="<?php print(urlencode($this->searchTerm)); ?>">
<?php
 viewRenderNavigation($this, $showNextLink, $showPrevLink);
?>
<div class="grid_15 topMargin bottomMargin">
	<h2 class="formHeader grid_5">SEARCH RESULTS (<?php print($this->search->totalCount); ?> item<?php print($this->search->totalCount != 1 ? 's' : ''); ?>)</h2>
<?php if ($this->search->totalCount > 0) { ?>
	<table class="grid_15 displayList bottomMargin">
<?php 
		$rowCount = 1;
		foreach($this->search->items as $searchIndex=>$item) {
			
			$rowClass = ($rowCount++ % 2) ? 'evenRow' : 'oddRow';
			 if (
			 	(is_array($this->hiddenRequests) && in_array($item->getItemID(),$this->hiddenRequests)) 
			 	|| (is_array($this->hiddenReserves) && in_array($item->getItemID(),$this->hiddenReserves)))
			 {
			 	$checked = ' checked="checked"';
			 } else {
			 	$checked = '';
			 }
?>
		<tr class="<?php print($rowClass);?>">
			<td class="centered">
				<img src="<?php print($item->getitemIcon());?>"/>
			</td>
			<td>
			<?php $this->getDisplayer()->renderItemDisplay(array(
				'item' => $item,
				'showIcon' => FALSE
			)); ?>
			</td>
			<td class="centered" width="10%">
<?php 
			if ($item->isElectronicItem()){ //#TODO implement an "isAutoProcessable option"
?>
				<input type="checkbox" name="reserve[<?php print($item->getItemID()); ?>]" value="<?php print($item->getItemID()); ?>" <?php print($checked);?>>
<?php 	
			} else {
?>
				<input type="checkbox" name="request[<?php print($item->getItemID()); ?>]" value="<?php print($item->getItemID()); ?>" <?php print($checked);?>>
<?php 
			}
			if ($item->isPhysicalItem() && !is_null($this->loanPeriods)) {
?>
			    <label class="smallerText">
			    	<div class="clearing  topMargin"></div>Requested <span class="class="nobreak"">Loan Period:</span></div>
				<?php $this->getDisplayer()->renderLoanPeriodSelect(array(
					'fieldName' => 'loanperiod[' . $item->getItemID() . ']',
					'periods' => $this->loanPeriods //#TODO this may not convey the items actually available because of home_library...
				)); ?>
				</label>
<?php 	    	
			}
?>	
			</td>
		</tr>
<?php 
		}

?>
	</table>
<?php } else { ?>
	<div class="bordered clearing basicPadding bottomMargin">No items matched your search.</div>
<?php } ?>
	<div class="clearing"></div>
<?php
 viewRenderNavigation($this, $showNextLink, $showPrevLink);
?>	
</div>
</form>